import {
  Component,
  ChangeDetectionStrategy,
  ViewEncapsulation,
  OnInit,
  ViewContainerRef,
  ElementRef,
  Renderer2,
  ChangeDetectorRef,
  Input,
  NgZone,
} from '@angular/core';
import { Overlay } from '@angular/cdk/overlay';
import { OverlayService } from '../core/overlay/api';
import { LvConfig } from '../core/config';
import { ThemeType, TooltipBaseComponent } from '../core/tooltipbase/api';

@Component({
  selector: 'lv-tooltip',
  templateUrl: '../core/tooltipbase/tooltip-base.component.html',
  exportAs: 'lvTooltipComponent',
  encapsulation: ViewEncapsulation.None,
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class TooltipComponent extends TooltipBaseComponent implements OnInit {
  @Input() lvOuterClosable = true; // 点击tooltip外部时是否关闭tooltip

  @Input() lvTheme: ThemeType = LvConfig.tooltipOptions.lvTheme || 'light'; // 主题颜色

  @Input() lvScrollToClose: boolean | { exclusions: HTMLElement[] } = true;

  constructor(
    public viewContainerRef: ViewContainerRef,
    public overlayService: OverlayService,
    public overlay: Overlay,
    public elementRef: ElementRef,
    public renderer: Renderer2,
    public cdr: ChangeDetectorRef,
    public ngZone: NgZone,
  ) {
    super(viewContainerRef, overlayService, overlay, elementRef, renderer, cdr, ngZone);
  }

  ngOnInit(): void {
    super.ngOnInit();
    this.type = 'tooltip';
  }
}
